###################################################
# This is MicroPlat's Makefile
#
# Compile(Debug): make clean;make
# Compile(Release): make clean;make mode=debug
#
# Author: yue
# Date: 2024-5-1
###################################################


# PATH
TC_DIR = .
TC_BIN_NAME = $(TC_DIR)
LIB_DIR = $(TC_DIR)/../lib

# PATH (INC/SRC)
TC_INC = $(TC_DIR)/../include
TC_SRC = $(TC_DIR)/*.c
TC_LIB = -L$(LIB_DIR) \
         -ldl         \
         -lpthread    \
         -lacl

# G++ OPTIONS
ifeq ($(mode), debug)
	CC = gcc -Wall -ggdb3 -fstack-protector-all -Wstack-protector -D_GNU_SOURCE -I$(TC_INC)
else
	CC = gcc -O3 -fstack-protector-all -Wstack-protector -D_GNU_SOURCE -I$(TC_INC)
endif

# BIN_NAME_NAME
BIN_NAME = tc

build:$(BIN_NAME)

$(BIN_NAME):
	@echo "Link all file"
	@$(CC) $(TC_SRC) $(TC_LIB) -o $(LIB_DIR)/$(BIN_NAME)
	@cd $(LIB_DIR); ldd $(BIN_NAME); cd -
	@echo "mv $(BIN_NAME) $(LIB_DIR)"
